
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 07/25/2012 21:40:32
-- Generated from EDMX file: c:\users\squadwuschel\documents\visual studio 2010\Projects\EFTest\EFData\Model.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [EFTest];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_PersonAuto]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[AutoMenge] DROP CONSTRAINT [FK_PersonAuto];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[PersonMenge]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PersonMenge];
GO
IF OBJECT_ID(N'[dbo].[AutoMenge]', 'U') IS NOT NULL
    DROP TABLE [dbo].[AutoMenge];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'PersonMenge'
CREATE TABLE [dbo].[PersonMenge] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [Vorname] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'AutoMenge'
CREATE TABLE [dbo].[AutoMenge] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Typ] nvarchar(max)  NOT NULL,
    [Kennzeichen] nvarchar(max)  NOT NULL,
    [PersonID] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [ID] in table 'PersonMenge'
ALTER TABLE [dbo].[PersonMenge]
ADD CONSTRAINT [PK_PersonMenge]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'AutoMenge'
ALTER TABLE [dbo].[AutoMenge]
ADD CONSTRAINT [PK_AutoMenge]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [PersonID] in table 'AutoMenge'
ALTER TABLE [dbo].[AutoMenge]
ADD CONSTRAINT [FK_PersonAuto]
    FOREIGN KEY ([PersonID])
    REFERENCES [dbo].[PersonMenge]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PersonAuto'
CREATE INDEX [IX_FK_PersonAuto]
ON [dbo].[AutoMenge]
    ([PersonID]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------